<template>
<section class="oa-form__table">
    <h5>{{ approve.name }}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">新建{{ approve.name }}</span>
          <span v-else>
            {{ approve.approve_name }}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
  <table>
    <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td width="400">
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
     <tr>
       <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name">评分说明</td>
        <td class="_name">数据来源</td>
        <td class="_name">自评</td>
        <td class="_name">评估得分</td>
     </tr>
      <tr>
       <td rowspan="5">设计</td>
       <td>整理照片</td>
       <td>20%</td>
       <td>收到工程部前一天提供的照片，在24小时内完成整理，并对照片拍照不合格的及时通知工程部用于上画工人考核。（24小时内未完成，扣2分）</td>
       <td>主管</td>
       <td><el-input v-model="obj.a121" :disabled="obj.a121Flag" /></td>
       <td><el-input v-model="obj.a129" :disabled="obj.a129Flag" /></td>
     </tr>
     <tr>
       <td>上下刊、监测报告</td>
       <td>20%</td>
       <td>设计部负责保证下单正确并对喷绘进度的跟踪，一般喷绘下单后第二天完成，游轮中心喷绘下单后三天内完成，漳州高速广告喷绘下单三天内完成，跟踪完成及时通知调度及可客服。（1、下单错误扣3分，赔偿公司喷绘费用。2、首次被选定无修改（加分条件：需2次以上（含2次）才可加分，每次加2分，只限老客户新设计版面以及新客户新版面，不计算老客户版面微小改动）</td>
       <td>客服部</td>
       <td><el-input v-model="obj.a122" :disabled="obj.a122Flag" /></td>
       <td><el-input v-model="obj.a130" :disabled="obj.a130Flag" /></td>
     </tr>
     <tr>
       <td>点位图</td>
       <td>20%</td>
       <td>在上下刊48小时内提供上下刊报告到客服（拖欠一天扣2分）</td>
       <td>客服部</td>
       <td><el-input v-model="obj.a123" :disabled="obj.a123Flag" /></td>
       <td><el-input v-model="obj.a131" :disabled="obj.a131Flag" /></td>
     </tr>
     <tr>
       <td rowspan="2">线路表的制作及点位巡查</td>
       <td>15%</td>
       <td>配合协助设计主管客户点位图制作及客户照片的处理，保证24小时内完成（拖欠一天扣2分）</td>
       <td>客服部</td>
       <td><el-input v-model="obj.a124" :disabled="obj.a124Flag" /></td>
       <td><el-input v-model="obj.a132" :disabled="obj.a132Flag" /></td>
     </tr>
     <tr>
       <td>15%</td>
       <td>按照工程部需求当天下单，喷绘公司于隔天配送（若数量少，采用快递方式，因此时间以快递送达时间为准）/每周形成工人照片/培训工人考核报告/媒体情况报告给调度（未达成一次扣2分）</td>
       <td> 调度</td>
       <td><el-input v-model="obj.a125" :disabled="obj.a125Flag" /></td>
       <td><el-input v-model="obj.a133" :disabled="obj.a133Flag" /></td>
     </tr>
     <tr>
       <td>公司自宣</td>
       <td>遵守公司规章制度</td>
       <td>10%</td>
       <td>对公司制度及公司文化的理解和执行（包括根据公司整体规划制定个人业务计划，合理安排个人各项工作时间，遵守公司各项制度等）</td>
       <td>督导</td>
       <td><el-input v-model="obj.a126" :disabled="obj.a126Flag" /></td>
       <td><el-input v-model="obj.a134" :disabled="obj.a134Flag" /></td>
     </tr>
     <tr>
       <td rowspan="2">加分项</td>
       <td>增量工作内容</td>
       <td>&nbsp;</td>
       <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
       <td>总经理</td>
       <td><el-input v-model="obj.a127" :disabled="obj.a127Flag" /></td>
       <td><el-input v-model="obj.a135" :disabled="obj.a135Flag" /></td>
     </tr>
      <tr>
       <td>对公司的建议</td>
       <td>&nbsp;</td>
       <td>对市场拓展、业务销售、内部管理等建设性意见</td>
       <td>总经理</td>
       <td><el-input v-model="obj.a128" :disabled="obj.a128Flag" /></td>
       <td><el-input v-model="obj.a136" :disabled="obj.a136Flag" /></td>
     </tr>
       <tr>
        <td colspan="5"></td>
        <td>自评:{{myScore}}</td>
        <td>综合考核率:{{otherScore}}</td>
      </tr>
 </table>
  <history :process="process"></history>
  <files></files>
</section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
// import { save, info, getAutoKey } from '@/api/oa/index.js'
const obj = {}
for (let i = 120; i <= 136; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    myScore () {
      const result = []
      for (let i = 121; i <= 128; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 129; i <= 136; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
